package rkdwogus7.practice;

import java.util.*;	

public class Ch04_Sil2_v2 {

	public static void main(String[] args) {
		Rectangle2 r2 = new Rectangle2();
		System.out.println(r2.toString());
		Scanner sc = new Scanner(System.in);
		System.out.println("두 점의 좌표를 입력하세요(x1,y1,x2,y2)");
		int i = sc.nextInt();
		int j = sc.nextInt();
		int k = sc.nextInt();
		int m = sc.nextInt();
		Rectangle2 s2 = new Rectangle2(i, j, k, m);
		System.out.println(s2.toString());
		if (r2.equals(r2)) {
			System.out.println("같은 사각형 입니다!");
		} else {
			System.out.println("같은 사각형이 아닙니다");
		}
			
		
		
		
	}

	
	
	
}

class Rectangle2 {
	private int x1 = 1;
	private int y1 = 1;
	private int x2 = 5;
	private int y2 = 5;
	private String result = "";
	
	public Rectangle2() { }
	public Rectangle2(int x1, int y1, int x2, int y2) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}
	
	public int square() {
		return (x2 - x1) * (y2 - y1);
	}
	
	public void setX1(int x1) {
		this.x1 = x1;
	}
	public int getX1() {
		return x1;
	}
	
	public void setY1(int y1) {
		this.y1 = y1;
	}
	public int getY1() {
		return y1;
	}
	
	public void setX2(int x2) {
		this.x2 = x2;
	}
	public int getX2() {
		return x2;
	}
	
	public void setY2(int y2) {
		this.y2 = y2;
	}
	public int getY2() {
		return y2;
	}
	
	 @Override
	public String toString() {
		result += "좌표 1의 값은 ( " + Integer.toString(x1) + " , " + Integer.toString(y1) + " )" + "\r\n";
		result += "좌표 2의 값은 ( " + Integer.toString(x2) + " , " + Integer.toString(y2) + " )" + "\r\n";
		result += "사각형의 넓이는 " + square() + "입니다.";
		return result;
	}
	
}














